package com.jycrm.service.cust.impl;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.jycrm.dao.cust.ICustClassDao;
import com.jycrm.domain.cust.CrmCustClass;
import com.jycrm.service.cust.ICustClassService;
import com.jycrm.util.DataDictConstantValue;



public class CustClassServiceImpl implements ICustClassService{
	private ICustClassDao custClassDao;
   

	public ICustClassDao getCustClassDao() {
		return custClassDao;
	}


	public void setCustClassDao(ICustClassDao custClassDao) {
		this.custClassDao = custClassDao;
	}


	public CrmCustClass findCustClassById(Long id){
		return custClassDao.findCustClassById(id);
	}
	public List getAllCustClassList() {
		return custClassDao.getAllCustClassList();
	}
	
	public List getCustClassSelectionList() {
		List temp = getAllCustClassList();
		List list = new ArrayList();
		if(list != null) {
        	Iterator it = temp.iterator();
            while(it.hasNext()){        
            	CrmCustClass tmpData=(CrmCustClass)it.next();
                String[][] value = new String[1][2];
                value[0][0] = tmpData.getId().toString();
                value[0][1] = tmpData.getName();
                list.add(value);
            }
        }
        return list;
	}
    
	public void saveCustClass(CrmCustClass custClass){
		custClassDao.saveCustClass(custClass);
	}
	public void updateCustClass(CrmCustClass custClass){
		custClassDao.updateCustClass(custClass);
	}
    public void cleanupCustClass(CrmCustClass custClass){	
    	custClass.setIsValid(DataDictConstantValue.DATADICT_GENERAL_NO_CODE);
        custClassDao.updateCustClass(custClass); 
    }
    public void delCustClass(CrmCustClass custClass){	
    	custClassDao.delCustClass(custClass); 
    }
}

